package com.company;

import java.util.Scanner;

public class GuessNumber {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        do {
            int guessNumber = (int) (Math.random() * 100) + 1;

            System.out.println("请猜测一个1-100的之间的数字");
            int i;
            for (i = 7; i > 0; i--) {
                int guess = scanner.nextInt();
                if (guess == guessNumber) {
                    System.out.println("你猜对了！");
                    break;
                } else if (guess < guessNumber) {
                    System.out.println("你猜的数小了");
                } else {
                    System.out.println("你猜的数大了");
                }
            }
            System.out.println("游戏结束。");
            System.out.println("是否再来一轮新的游戏？(Y/N)");
        }while (scanner.next().equalsIgnoreCase("y"));
    }
}
